/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tabelamodelcolumnmodel.cliente;

import eloma.classe.Cliente;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Icaro
 */
public class ClienteTableModel extends AbstractTableModel {

    private List<Cliente> listCliente;
    private boolean ordenarPorNome = true;

    public ClienteTableModel(List<Cliente> listCliente) {
        this.listCliente = listCliente;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Cliente cliente = listCliente.get(rowIndex);
        switch (columnIndex) {
            case 0:
                return cliente.getNome();
            case 1:
                return cliente.getTelefone();
        }

        return null;
    }

    @Override
    public int getRowCount() {
        return listCliente.size();
    }

    @Override
    public int getColumnCount() {
        return 2;
    }

    public Cliente getValoresCliente(int rowIndex) {
        return listCliente.get(rowIndex);
    }

    public boolean isOrdenarPorNome() {
        return ordenarPorNome;
    }

    public void setOrdenarPorNome(boolean ordenarPorNome) {
        this.ordenarPorNome = ordenarPorNome;
    }

}
